#!/bin/bash
##########################################################################
# File Name: gcs_init.sh
# Author: wangdj
# mail: wangdajunzy@163.com
# Created Time: 2020 06 11
##########################################################################

echored(){
  echo -e "\e[31m$*\e[0m"
}

#if ! echo $(pwd) |grep -q '^/root'; then
#  echored 'not home'
#  exit
#fi

# git clone path
colabinitpath=colab-init
#
## config vim
#if ! [ -f $colabinitpath/vimrc-min ]; then
#wget https://gitee.com/ttf0815/publicfile/raw/master/vimrc-min
#fi
#mv -v vimrc-min /root/.vimrc

## config history format
#grep -q 'HISTTIMEFORMAT=' .bashrc || echo 'export HISTTIMEFORMAT="%F %T "' >> .bashrc
## config delete readme file
#grep -q 'README-cloudshell' .bashrc || echo 'rm -f README-cloudshell.txt' >> .bashrc
## config time zone
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

##apt-get install -y dos2unix expect screen rsync

# install gclone as rclone
if ! [ -f /usr/bin/rclone ]; then
  wget https://github.com/donwa/gclone/releases/download/v1.51.0-mod1.3.1/gclone_1.51.0-mod1.3.1_Linux_x86_64.gz
  gunzip gclone_1.51.0-mod1.3.1_Linux_x86_64.gz
  mv -v gclone_1.51.0-mod1.3.1_Linux_x86_64 /usr/bin/rclone
  chmod +x  /usr/bin/rclone
else
    echored "rclone already install in /usr/bin/rclone" 
fi

# config gclone as rclone
if [ -f $colabinitpath/rclone.conf ]; then
  mkdir -p /root/.config/rclone/
  cp -av $colabinitpath/rclone.conf /root/.config/rclone/
else
  echored "no gclone.conf file"
  exit
fi

## config sa
#l="wdjddf-1400SA-ttf0815@googlegroups.com.zip"
#
##rclone="gopath/bin/rclone --config .config/rclone/rclone.conf"
#for i in $l; do
#  echored $i
#  rclone copy -v gd:_af/$i .
#  unzip $i >/dev/null || echored "unzip $i fail"
#  rm -fv $i
#done

#install rar
#wget https://www.rarlab.com/rar/rarlinux-x64-5.9.1.tar.gz
